<div class="col-md-12 col-sm-12 col-xs-12">
    <div class="x_panel">
        <div class="x_title">
            <h2>{$pri_name}</h2>
            <div class="clearfix"></div>
        </div>
        <div class="x_content">
            <form class="form-horizontal form-label-left" novalidate action="" id="commentForm" method="post" enctype="multipart/form-data">
                {notempty name="code"}<p><code>备注:</code>{$code}</a></p>{/notempty}
                <!--<span class="section">Personal Info</span>-->
                {:html_text('标题','title',$info)}
                {:html_select('类型','type_id',$info,$banner_type)}
                {:html_upload_one('单个图片','single_pic',$info,['180','180'])}
                {:html_radio('跳转方式','jump_way',$info, [1=>'无跳转',2=>'url',3=>'详情',4=>'信息页面'])}
                {:html_text('url','url',$info)}

                {:html_editor('内容','content',$info)}

                {:html_text('跳转ID','view_id',$info)}
                {:html_number('排序','sort',$info,100)}
                {:html_radio('状态','status',$info, [1=>'开启',2=>'关闭'])}
                {:html_datetime('创建时间','create_time',$info)}
                <div class="ln_solid"></div>
                <div class="form-group">
                    <div class="col-md-6 col-md-offset-3">
                        <button id="send" type="submit" class="btn btn-success">提交</button>
                        <div class="btn btn-primary" onclick="history.go(-1)">返回</div>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
<script>
    $('[name="url"]').parent().parent().hide();
    $('[name="view_id"]').parent().parent().hide();
    $('[name="content"]').parent().parent().hide();
    $('[name="score_id"]').parent().parent().hide();

    $('[name="jump_way"]').click(function () {
        $('[name="url"]').parent().parent().hide();
        $('[name="view_id"]').parent().parent().hide();
        $('[name="content"]').parent().parent().hide();
        $('[name="score_id"]').parent().parent().hide();
        $('[name="view_id"]').removeAttr('required');
        $('[name="url"]').removeAttr('required');
        $('[name="score_id"]').removeAttr('required');
        var v = $(this).val();
        if (v == 1) {

        }
        if (v == 2) {
            $('[name="url"]').parent().parent().show();
            $('[name="url"]').attr('required','required');
        }
        if (v == 3) {
            $('[name="content"]').parent().parent().show();
        }
        if (v == 4) {
            $('[name="view_id"]').parent().parent().show();
            $('[name="score_id"]').parent().parent().show();
        }

    });

    var action = "{:request()->action()}";

    if(action == 'update'){
        var jump_way = "{$info.jump_way|default=1}";
        if(jump_way == 1){
            $('[name="url"]').removeAttr('required');
            $('[name="score_id"]').removeAttr('required');
        }
        if(jump_way == 2){
            $('[name="url"]').parent().parent().show();
            $('[name="url"]').attr('required','required');
            $('[name="score_id"]').removeAttr('required');
        }
        if(jump_way == 3){
            $('[name="content"]').parent().parent().show();
            $('[name="url"]').removeAttr('required');
            $('[name="score_id"]').removeAttr('required');
        }
        if(jump_way == 4){

            $('[name="view_id"]').parent().parent().show();
            $('[name="score_id"]').parent().parent().show();

            $('[name="url"]').removeAttr('required');

        }
    }

</script>
